package org.example;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:何人亮
 * Date:2024-11-11
 * 22:43
 */
class Test{
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt( );
        int[ ] arr=new int[n];
        for(int i=0;i<n;i++){
            arr[i]=sc.nextInt();
        }
        for(int i=0, count=0;i<n&&count<n;i++){
            if(arr[i]==0){
                if(i!=n-1){
                    count+=2;
                    if(count<=n){
                        System.out.printf(arr[i]+" ");
                        System.out.printf(arr[i]+" ");
                    }else{
                        System.out.printf(arr[i]+" ");

                    }
                }else{
                    System.out.print(arr[i]);
                }
            }else{
                if(i!=n-1){
                    System.out.printf(arr[i]+" ");
                    count+=1;
                }else{
                    System.out.print(arr[i]);
                }
            }
        }
    }
}
